// [[ OnflowGenerator File UUID: 0e2f92026a1f4711bc833ca555919dfe  ]]
package com.itdct.onflow.system.dict.controller

import com.itdct.onflow.core.type.*
import com.itdct.onflow.core.vo.KeyLabelValueVo
import com.itdct.onflow.core.vo.RespPageVo
import com.itdct.onflow.core.vo.RespVo
import com.itdct.onflow.system.common.base.BaseSysController
import com.itdct.onflow.system.dict.qo.SysDictEditQo
import com.itdct.onflow.system.dict.qo.SysDictSearchQo
import com.itdct.onflow.system.dict.service.SysDictService
import com.itdct.onflow.system.dict.vo.SysDictDetailVo
import com.itdct.onflow.system.dict.vo.SysDictListVo
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.*

/**
 * @author DCTANT
 * @date 2025-09-01 14:43:30
 * @version 1.0
 * @description 系统字典接口控制
 */
@Tag(name = SysDictController.moduleName)
@RestController
@RequestMapping(value = ["/sysDict"], produces = [MediaType.APPLICATION_JSON_VALUE], method = [RequestMethod.POST])
class SysDictController(
    val sysDictService: SysDictService
) : BaseSysController() {
    companion object {
        const val moduleName = "系统字典"
    }

    @Operation(summary = moduleName + "添加")
    @PostMapping("/add.adw")
    fun add(@RequestBody @Validated(Add::class) qo: SysDictEditQo): RespVo<Long> {
        return sysDictService.add(qo, getContext())
    }

    @Operation(summary = moduleName + "更新")
    @PostMapping("/update.adw")
    fun update(@RequestBody @Validated(Update::class) qo: SysDictEditQo): RespVo<Unit> {
        return sysDictService.update(qo, getContext())
    }

    @Operation(summary = moduleName + "删除")
    @PostMapping("/delete.adw")
    fun delete(@RequestBody @Validated(Delete::class) qo: SysDictEditQo): RespVo<Unit> {
        return sysDictService.delete(qo, getContext())
    }

    @Operation(summary = moduleName + "详情")
    @PostMapping("/detail.adw")
    fun detail(@RequestBody @Validated(Detail::class) qo: SysDictSearchQo): RespVo<SysDictDetailVo> {
        return sysDictService.detail(qo, getContext())
    }

    @Operation(summary = moduleName + "列表")
    @PostMapping("/page.adw")
    fun page(@RequestBody @Validated(Page::class) qo: SysDictSearchQo): RespPageVo<SysDictListVo> {
        return sysDictService.page(qo, getContext())
    }

    // [[ OnflowGenerator Range (- selectFunctions -) Start ]]
    @Operation(summary = moduleName + "字典码下拉选")
    @PostMapping("/selectCodeList.adw")
    fun selectCodeList(@RequestBody qo: SysDictSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysDictService.selectCodeList(qo, getContext())
    }

    @Operation(summary = moduleName + "字典值下拉选")
    @PostMapping("/selectNameList.adw")
    fun selectNameList(@RequestBody qo: SysDictSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysDictService.selectNameList(qo, getContext())
    }

    @Operation(summary = moduleName + "字典下拉选")
    @PostMapping("/chooseDictList.adw")
    fun chooseList(@RequestBody qo: SysDictSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysDictService.chooseDictList(qo, getContext())
    }
// [[ OnflowGenerator Range (- selectFunctions -) End ]]

    @Operation(summary = moduleName + "刷新字典缓存")
    @PostMapping("/refreshDict.adw")
    fun refreshDict(): RespVo<Unit> {
        return sysDictService.refreshDict(getContext())
    }

    @Operation(summary = moduleName + "字典子列表")
    @PostMapping("/childrenList.adw")
    fun childrenList(@RequestBody qo: SysDictSearchQo): RespVo<List<SysDictListVo>> {
        return sysDictService.childrenList(qo, getContext())
    }
}